package com.binyouwei.designpatterns.behavior.strategy;

import javax.naming.Context;

/**
 * @author 宾有为
 * Created on 2024/7/15 22:10
 * Social homepage: https://blog.csdn.net/baidu_41616022
 * @desc 策略模式 - 一个类的行为或其算法可以在运行时更改。这种类型的设计模式属于行为型模式。
 **/
public class StrategyMain {
    public static void main(String[] args) {
        StrategyContext context = new StrategyContext(new StrategyOperationAdd());
        System.out.println("10 + 5 = " + context.executeStrategy(10, 5));

        context = new StrategyContext(new StrategyOperationSubtract());
        System.out.println("10 - 5 = " + context.executeStrategy(10, 5));

        context = new StrategyContext(new StrategyOperationMultiply());
        System.out.println("10 * 5 = " + context.executeStrategy(10, 5));
    }
}
